package com.tnxst.phexamination.room.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.tnxst.phexamination.dto.DiabetesFollowDTO;
import com.tnxst.phexamination.dto.DoctorDTO;
import com.tnxst.phexamination.dto.HypertensionFollowDTO;
import com.tnxst.phexamination.dto.InhabitantDTO;
import com.tnxst.phexamination.dto.ServiceDetailsDTO;
import com.tnxst.phexamination.dto.ServicePackageDTO;
import com.tnxst.phexamination.dto.SignDTO;
import com.tnxst.phexamination.dto.TCMHealthDTO;
import com.tnxst.phexamination.dto.TbFirstFollowDTO;
import com.tnxst.phexamination.dto.TbFollowDTO;
import com.tnxst.phexamination.dto.TbPatientDTO;
import com.tnxst.phexamination.dto.TbPatientRecordDTO;
import com.tnxst.phexamination.dto.TeamDoctorDTO;
import com.tnxst.phexamination.room.converters.Converters;
import com.tnxst.phexamination.room.dao.DiabetesFollowDao;
import com.tnxst.phexamination.room.dao.DoctorDao;
import com.tnxst.phexamination.room.dao.HypertensionFollowDao;
import com.tnxst.phexamination.room.dao.InhabitantDao;
import com.tnxst.phexamination.room.dao.ServiceDetailsDao;
import com.tnxst.phexamination.room.dao.ServicePackageDao;
import com.tnxst.phexamination.room.dao.SignDao;
import com.tnxst.phexamination.room.dao.TCMHealthDao;
import com.tnxst.phexamination.room.dao.TbFirstFollowDao;
import com.tnxst.phexamination.room.dao.TbFollowDao;
import com.tnxst.phexamination.room.dao.TbPatientDao;
import com.tnxst.phexamination.room.dao.TbPatientRecordDao;
import com.tnxst.phexamination.room.dao.TeamDoctorDao;

@TypeConverters({Converters.class})
@Database(entities = {ServicePackageDTO.class, ServiceDetailsDTO.class, SignDTO.class,
        InhabitantDTO.class, TeamDoctorDTO.class, TbFirstFollowDTO.class, TbFollowDTO.class,
        TbPatientRecordDTO.class, TbPatientDTO.class, DiabetesFollowDTO.class, HypertensionFollowDTO.class,
        TCMHealthDTO.class, DoctorDTO.class}, version = 1, exportSchema = false)
public abstract class PhexaminationDatabase extends RoomDatabase {
    private static PhexaminationDatabase getInstance;

    public static synchronized PhexaminationDatabase getDatabase(Context context, String account) {
        if (getInstance == null) {
            getInstance = Room.databaseBuilder(context.getApplicationContext(), PhexaminationDatabase.class, "phexamination")
                    .build();
        }
        return getInstance;
    }

    static final Migration MIGRATION_3_4 = new Migration(2, 3) {
        @Override
        public void migrate(SupportSQLiteDatabase database) {
            // Since we didn't alter the table, there's nothing else to do here.
        }
    };

    public abstract ServicePackageDao getServicePackageDao();

    public abstract ServiceDetailsDao getServiceDetailsDao();

    public abstract SignDao getSignDao();

    public abstract InhabitantDao getInhabitantDao();

    public abstract TeamDoctorDao getTeamDoctorDao();

    public abstract TbFirstFollowDao getTbFirstFollowDao();

    public abstract TbFollowDao getTbFollowDao();

    public abstract TbPatientRecordDao getTbPatientRecordDao();

    public abstract TbPatientDao getTbPatientDao();

    public abstract DiabetesFollowDao getDiabetesFollowDao();

    public abstract HypertensionFollowDao getHypertensionFollowDao();

    public abstract TCMHealthDao getTCMHealthDao();

    public abstract DoctorDao getDoctorDao();
}